<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <script>
    var gaProperty = 'UA-2577926-1';
    // Disable tracking if the opt-out cookie exists.
    var disableStr = 'ga-disable-' + gaProperty;
    if (document.cookie.indexOf(disableStr + '=true') > -1) {
      window[disableStr] = true;
    }
    function gaOptout() {
      document.cookie = disableStr + '=true; expires=Thu, 31 Dec 2099 23:59:59 UTC; path=/';
      window[disableStr] = true;
    }
    function gaOptoutRevoke() {
      document.cookie = disableStr + '=false; expires=Thu, 31 Dec 2099 23:59:59 UTC; path=/';
      window[disableStr] = false;
    }
    </script>
    <!-- Global site tag (gtag.js) - Google Analytics -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=UA-2577926-1"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());
      gtag('config', 'UA-2577926-1', { 'anonymize_ip': true });
    </script>
    <link type="text/css" rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.1.0/cookieconsent.min.css" />
    <script src="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.1.0/cookieconsent.min.js"></script>
    <script>
    window.addEventListener("load", function() {
      window.cookieconsent.initialise({
        'palette': {
          'popup': {
            'background': '#eaf7f7',
            'text': '#5c7291'
          },
          'button': {
            'background': '#56cbdb',
            'text': '#ffffff'
          }
        },
        'theme': 'edgeless',
        'type': 'opt-out',
        'onInitialise': function (status) {
          if (!this.hasConsented()) {
            gaOptout()
          }
        },
        'onStatusChange': function(status, chosenBefore) {
          if (!this.hasConsented()) {
            gaOptout()
          }
        },
        'onRevokeChoice': function() {
          gaOptoutRevoke()
        }
      })
    });
    </script>
    <title>OpenLayers v6.13.0 API - Module: ol/events/condition</title>
    <script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=fetch"></script>
    <script src="scripts/prettify/prettify.js"></script>
    <script src="scripts/prettify/lang-css.js"></script>
    <script src="scripts/jquery.min.js"></script>
    <script src="scripts/bootstrap.bundle.min.js"></script>
    <!--[if lt IE 9]>
      <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <link type="text/css" rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
    <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
    <link type="text/css" rel="stylesheet" href="styles/bootstrap.min.css">
    <link type="text/css" rel="stylesheet" href="styles/jaguar.css">
    <link type="text/css" rel="stylesheet" href="styles/site.css">
  </head>
  <body>
    <div class="container-fluid">
      <header class="navbar navbar-expand-sm navbar-dark mb-3 py-0 fixed-top" role="navigation">
        <a class="navbar-brand" href="https://openlayers.org/"><img src="logo-70x70.png" alt="">&nbsp;OpenLayers</a>

        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#olmenu" aria-controls="olmenu" aria-expanded="false" aria-label="Toggle navigation">
          <span class="navbar-toggler-icon"></span>
        </button>

        <!-- menu items that get hidden below 768px width -->
        <nav class="collapse navbar-collapse" id="olmenu">
          <ul class="navbar-nav ml-auto">
          <li class="nav-item dropdown">
            <a class="nav-link dropdown-toggle" href="#" id="docdropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Docs</a>
            <div class="dropdown-menu dropdown-menu-right" aria-labelledby="docdropdown">
              <a class="dropdown-item" href="/en/latest/doc/">Docs</a>
              <div class="dropdown-divider"></div>
                <a class="dropdown-item" href="../doc/quickstart.html"><i class="fa fa-check fa-fw mr-2 fa-lg"></i>Quick Start</a>
                <a class="dropdown-item" href="../doc/faq.html"><i class="fa fa-question fa-fw mr-2 fa-lg"></i>FAQ</a>
                <a class="dropdown-item" href="../doc/tutorials/"><i class="fa fa-book fa-fw mr-2 fa-lg"></i>Tutorials</a>
                <a class="dropdown-item" href="/workshop/"><i class="fa fa-graduation-cap fa-fw mr-2 fa-lg"></i>Workshop</a>
                <div class="dropdown-divider"></div>
                <a class="dropdown-item" href="https://stackoverflow.com/questions/tagged/openlayers"><i class="fa fa-stack-overflow fa-fw mr-2"></i>Ask a Question</a>
            </div>
          </li>
          <li class="nav-item"><a class="nav-link" href="../examples/">Examples</a></li>
          <li class="nav-item active"><a class="nav-link" href="../apidoc/"><i class="fa fa-sitemap mr-1"></i>API</a></li>
          <li class="nav-item dropdown">
            <a class="nav-link dropdown-toggle" href="#" id="codedropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Code</a>
            <div class="dropdown-menu dropdown-menu-right" aria-labelledby="codedropdown">
              <a class="dropdown-item" href="https://github.com/openlayers/openlayers"><i class="fa fa-github fa-fw mr-2 fa-lg"></i>Repository</a>
              <a class="dropdown-item" href="/download/"><i class="fa fa-download fa-fw mr-2 fa-lg"></i>Download</a>
            </div>
           </li>
          </ul>
        </nav>
      </header>
      <div id="wrap" class="row">
        <div class="navigation col-md-4 col-lg-3">
          <div class="search-wrapper">
            <div class="search">
              <input id="search" type="text" autocomplete="off" class="form-control input-sm" placeholder="Search Documentation">
            </div>
          </div>
          <div class="navigation-list-wrapper">
            <ul class="navigation-list search-empty">
<li class="item item-module toggle-manual toggle-manual-show" data-longname="module:ol/events/condition" data-name="ol/events/condition">
    <span class="title toggle">
        <span class="fa fa-plus mr-2 mt-1"></span>
        <span><a href="module-ol_events_condition.html">ol​/events​/condition</a></span>
    </span>
    <div class="member-list" data-type="members">
        <span class="subtitle">Members</span>
        <ul>
            <li data-name="altkeyonly"><a href="module-ol_events_condition.html#.altKeyOnly">altKeyOnly</a>
            <li data-name="altshiftkeysonly"><a href="module-ol_events_condition.html#.altShiftKeysOnly">altShiftKeysOnly</a>
            <li data-name="always"><a href="module-ol_events_condition.html#.always">always</a>
            <li data-name="click"><a href="module-ol_events_condition.html#.click">click</a>
            <li data-name="doubleclick"><a href="module-ol_events_condition.html#.doubleClick">doubleClick</a>
            <li data-name="focus"><a href="module-ol_events_condition.html#.focus">focus</a>
            <li data-name="mouseonly"><a href="module-ol_events_condition.html#.mouseOnly">mouseOnly</a>
            <li data-name="never"><a href="module-ol_events_condition.html#.never">never</a>
            <li data-name="nomodifierkeys"><a href="module-ol_events_condition.html#.noModifierKeys">noModifierKeys</a>
            <li data-name="penonly"><a href="module-ol_events_condition.html#.penOnly">penOnly</a>
            <li data-name="platformmodifierkeyonly"><a href="module-ol_events_condition.html#.platformModifierKeyOnly">platformModifierKeyOnly</a>
            <li data-name="pointermove"><a href="module-ol_events_condition.html#.pointerMove">pointerMove</a>
            <li data-name="primaryaction"><a href="module-ol_events_condition.html#.primaryAction">primaryAction</a>
            <li data-name="shiftkeyonly"><a href="module-ol_events_condition.html#.shiftKeyOnly">shiftKeyOnly</a>
            <li data-name="singleclick"><a href="module-ol_events_condition.html#.singleClick">singleClick</a>
            <li data-name="targetnoteditable"><a href="module-ol_events_condition.html#.targetNotEditable">targetNotEditable</a>
            <li data-name="touchonly"><a href="module-ol_events_condition.html#.touchOnly">touchOnly</a>
        </ul>
    </div>
    <div class="member-list" data-type="typedefs">
        <span class="subtitle">Typedefs</span>
        <ul>
            <li data-name="condition"><a href="module-ol_events_condition.html#~Condition">Condition</a>
        </ul>
    </div>
              <li class="loading">Loading …
            </ul>
          </div>
        </div>

        <div class="main col-md-8 col-lg-9">
            <h1 class="page-title" data-filename="module-ol_events_condition.html">Module: ol/events/condition</h1>
            <div id="latest-check" class="alert alert-warning alert-dismissible" role="alert" style="display:none">
              <button id="latest-dismiss" type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
              This documentation is for OpenLayers v<span id="package-version">6.13.0</span>. The <a id="latest-link" href="#" class="alert-link">latest</a> is v<span id="latest-version"></span>.
            </div>
            



<section class="content">

<header>
    <h2 class="my-3">ol/events/condition
    </h2>
    <br>
    
      
      
    
    <div class="row p-3 ">
      <div id="ad" class="col-lg-5 order-2 align-self-center border rounded bg-light ">
        <script async type="text/javascript" src="https://cdn.carbonads.com/carbon.js?serve=CE7DV53U&placement=openlayersorg" id="_carbonads_js"></script>
      </div>
    
    </div>
</header>

<article>
    <div class="container-overview">
    

    
        

        
<dl class="details">
    
        
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
</dl>


        
    
    </div>

    

    

    

    

    

    

    

    
        <h3 class="subsection-title">Members</h3>

        <dl>
            
<dt class="">
    <div class="nameContainer">
        <div class="anchor" id=".altKeyOnly">
        </div>
        <h4 class="name">
            module:ol/events/condition.altKeyOnly
            

        </h4>
    </div>
    
</dt>
<dd class="">
    
    <div class="description">
        <p>Return <code>true</code> if only the alt-key is pressed, <code>false</code> otherwise (e.g. when
additionally the shift-key is pressed).</p>
    </div>
    

    
<dl class="details">
    
        
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
</dl>


    
</dd>

        
            
<dt class="">
    <div class="nameContainer">
        <div class="anchor" id=".altShiftKeysOnly">
        </div>
        <h4 class="name">
            module:ol/events/condition.altShiftKeysOnly
            

        </h4>
    </div>
    
</dt>
<dd class="">
    
    <div class="description">
        <p>Return <code>true</code> if only the alt-key and shift-key is pressed, <code>false</code> otherwise
(e.g. when additionally the platform-modifier-key is pressed).</p>
    </div>
    

    
<dl class="details">
    
        
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
</dl>


    
</dd>

        
            
<dt class="">
    <div class="nameContainer">
        <div class="anchor" id=".always">
        </div>
        <h4 class="name">
            module:ol/events/condition.always
            

        </h4>
    </div>
    
</dt>
<dd class="">
    
    <div class="description">
        <p>Return always true.</p>
    </div>
    

    
<dl class="details">
    
        
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
</dl>


    
</dd>

        
            
<dt class="">
    <div class="nameContainer">
        <div class="anchor" id=".click">
        </div>
        <h4 class="name">
            module:ol/events/condition.click
            

        </h4>
    </div>
    
</dt>
<dd class="">
    
    <div class="description">
        <p>Return <code>true</code> if the event is a <code>click</code> event, <code>false</code> otherwise.</p>
    </div>
    

    
<dl class="details">
    
        
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
</dl>


    
</dd>

        
            
<dt class="">
    <div class="nameContainer">
        <div class="anchor" id=".doubleClick">
        </div>
        <h4 class="name">
            module:ol/events/condition.doubleClick
            

        </h4>
    </div>
    
</dt>
<dd class="">
    
    <div class="description">
        <p>Return <code>true</code> if the event is a map <code>dblclick</code> event, <code>false</code> otherwise.</p>
    </div>
    

    
<dl class="details">
    
        
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
</dl>


    
</dd>

        
            
<dt class="">
    <div class="nameContainer">
        <div class="anchor" id=".focus">
        </div>
        <h4 class="name">
            module:ol/events/condition.focus
            

        </h4>
    </div>
    
</dt>
<dd class="">
    
    <div class="description">
        <p>Return <code>true</code> if the map has the focus. This condition requires a map target
element with a <code>tabindex</code> attribute, e.g. <code>&lt;div id=&quot;map&quot; tabindex=&quot;1&quot;&gt;</code>.</p>
    </div>
    

    
<dl class="details">
    
        
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
</dl>


    
</dd>

        
            
<dt class="">
    <div class="nameContainer">
        <div class="anchor" id=".mouseOnly">
        </div>
        <h4 class="name">
            module:ol/events/condition.mouseOnly
            

        </h4>
    </div>
    
</dt>
<dd class="">
    
    <div class="description">
        <p>Return <code>true</code> if the event originates from a mouse device.</p>
    </div>
    

    
<dl class="details">
    
        
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
</dl>


    
</dd>

        
            
<dt class="">
    <div class="nameContainer">
        <div class="anchor" id=".never">
        </div>
        <h4 class="name">
            module:ol/events/condition.never
            

        </h4>
    </div>
    
</dt>
<dd class="">
    
    <div class="description">
        <p>Return always false.</p>
    </div>
    

    
<dl class="details">
    
        
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
</dl>


    
</dd>

        
            
<dt class="">
    <div class="nameContainer">
        <div class="anchor" id=".noModifierKeys">
        </div>
        <h4 class="name">
            module:ol/events/condition.noModifierKeys
            

        </h4>
    </div>
    
</dt>
<dd class="">
    
    <div class="description">
        <p>Return <code>true</code> if no modifier key (alt-, shift- or platform-modifier-key) is
pressed.</p>
    </div>
    

    
<dl class="details">
    
        
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
</dl>


    
</dd>

        
            
<dt class="">
    <div class="nameContainer">
        <div class="anchor" id=".penOnly">
        </div>
        <h4 class="name">
            module:ol/events/condition.penOnly
            

        </h4>
    </div>
    
</dt>
<dd class="">
    
    <div class="description">
        <p>Return <code>true</code> if the event originates from a digital pen.</p>
    </div>
    

    
<dl class="details">
    
        
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
</dl>


    
</dd>

        
            
<dt class="">
    <div class="nameContainer">
        <div class="anchor" id=".platformModifierKeyOnly">
        </div>
        <h4 class="name">
            module:ol/events/condition.platformModifierKeyOnly
            

        </h4>
    </div>
    
</dt>
<dd class="">
    
    <div class="description">
        <p>Return <code>true</code> if only the platform-modifier-key (the meta-key on Mac,
ctrl-key otherwise) is pressed, <code>false</code> otherwise (e.g. when additionally
the shift-key is pressed).</p>
    </div>
    

    
<dl class="details">
    
        
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
</dl>


    
</dd>

        
            
<dt class="">
    <div class="nameContainer">
        <div class="anchor" id=".pointerMove">
        </div>
        <h4 class="name">
            module:ol/events/condition.pointerMove
            

        </h4>
    </div>
    
</dt>
<dd class="">
    
    <div class="description">
        <p>Return <code>true</code> if the browser event is a <code>pointermove</code> event, <code>false</code>
otherwise.</p>
    </div>
    

    
<dl class="details">
    
        
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
</dl>


    
</dd>

        
            
<dt class="">
    <div class="nameContainer">
        <div class="anchor" id=".primaryAction">
        </div>
        <h4 class="name">
            module:ol/events/condition.primaryAction
            

        </h4>
    </div>
    
</dt>
<dd class="">
    
    <div class="description">
        <p>Return <code>true</code> if the event originates from a primary pointer in
contact with the surface or if the left mouse button is pressed.
See <a href="https://www.w3.org/TR/pointerevents/#button-states">https://www.w3.org/TR/pointerevents/#button-states</a>.</p>
    </div>
    

    
<dl class="details">
    
        
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
</dl>


    
</dd>

        
            
<dt class="">
    <div class="nameContainer">
        <div class="anchor" id=".shiftKeyOnly">
        </div>
        <h4 class="name">
            module:ol/events/condition.shiftKeyOnly
            

        </h4>
    </div>
    
</dt>
<dd class="">
    
    <div class="description">
        <p>Return <code>true</code> if only the shift-key is pressed, <code>false</code> otherwise (e.g. when
additionally the alt-key is pressed).</p>
    </div>
    

    
<dl class="details">
    
        
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
</dl>


    
</dd>

        
            
<dt class="">
    <div class="nameContainer">
        <div class="anchor" id=".singleClick">
        </div>
        <h4 class="name">
            module:ol/events/condition.singleClick
            

        </h4>
    </div>
    
</dt>
<dd class="">
    
    <div class="description">
        <p>Return <code>true</code> if the event is a map <code>singleclick</code> event, <code>false</code> otherwise.</p>
    </div>
    

    
<dl class="details">
    
        
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
</dl>


    
</dd>

        
            
<dt class="">
    <div class="nameContainer">
        <div class="anchor" id=".targetNotEditable">
        </div>
        <h4 class="name">
            module:ol/events/condition.targetNotEditable
            

        </h4>
    </div>
    
</dt>
<dd class="">
    
    <div class="description">
        <p>Return <code>true</code> if the target element is not editable, i.e. not a <code>&lt;input&gt;</code>-,
<code>&lt;select&gt;</code>- or <code>&lt;textarea&gt;</code>-element, <code>false</code> otherwise.</p>
    </div>
    

    
<dl class="details">
    
        
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
</dl>


    
</dd>

        
            
<dt class="">
    <div class="nameContainer">
        <div class="anchor" id=".touchOnly">
        </div>
        <h4 class="name">
            module:ol/events/condition.touchOnly
            

        </h4>
    </div>
    
</dt>
<dd class="">
    
    <div class="description">
        <p>Return <code>true</code> if the event originates from a touchable device.</p>
    </div>
    

    
<dl class="details">
    
        
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
</dl>


    
</dd>

        </dl>
    

    

    
        <h3 class="subsection-title">Type Definitions</h3>

        <dl>
                
<dt class="">
    
    <div class="nameContainer">
        <div class="anchor" id="~Condition">
        </div>
        <h4 class="name">
            Condition<span class="signature">()</span>
            
            

        </h4>
        
        <div class="tag-source">
            <a href="https://github.com/openlayers/openlayers/blob/v6.13.0/src/ol/events/condition.js">events/condition.js</a>,
            <a href="https://github.com/openlayers/openlayers/blob/v6.13.0/src/ol/events/condition.js#L9">line 9</a>
        </div>
        
    </div>
    
    
</dt>
<dd class="">



    
    <div class="description">
        <p>A function that takes an <a href="module-ol_MapBrowserEvent-MapBrowserEvent.html"><code>module:ol/MapBrowserEvent~MapBrowserEvent</code></a> and returns a
<code>{boolean}</code>. If the condition is met, true should be returned.</p>
    </div>
    

    

    

    
    
    

    
<dl class="details">
    
        
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
</dl>


    

    

    

    

    

    
</dd>

            </dl>
    

    
</article>

</section>




        </div>
      </div>
      <script>prettyPrint();</script>
      <script src="scripts/linenumber.js"></script>
      <script src="scripts/main.js"></script>
    </div>
  </body>
</html>